
#include <iostream>
#include <vector>
#include <algorithm>
#include <chrono>
#include <string>

using namespace std;

int main() {
    vector<string> m1, m2, m3;
    string filename1 = "m1_sorted.txt";
    string filename2 = "m2_reverse.txt";
    string filename3 = "m3_shuffle.txt";

    m1 = read2list(filename1);
    m2 = read2list(filename2);
    m3 = read2list(filename3);

    auto t_start = chrono::high_resolution_clock::now();
    sort(m1.begin(), m1.end());
    auto t_finish = chrono::high_resolution_clock::now();
    cout << "m1_sorted" << chrono::duration<double, milli>(t_finish - t_start).count() << " milliseconds" << endl;

    t_start = chrono::high_resolution_clock::now();
    sort(m2.rbegin(), m2.rend());
    t_finish = chrono::high_resolution_clock::now();
    cout << "m2_reverse" << chrono::duration<double, milli>(t_finish - t_start).count() << " milliseconds" << endl;

    t_start = chrono::high_resolution_clock::now();
    shuffle(m3.begin(), m3.end(), random_device{}());
    sort(m3.begin(), m3.end());
    t_finish = chrono::high_resolution_clock::now();
    cout << "m3_shuffle" << chrono::duration<double, milli>(t_finish - t_start).count() << " milliseconds" << endl;

    return 0;
}

vector<string> read2list(string filename) {
    vector<string> data;
    ifstream file(filename);
    string line;
    while (getline(file, line)) {
        data.push_back(line);
    }
    return data;
}